package com.itheima.Array.DoublePointer;

/**
 * @Author: Ethan Yankang
 * @Program: code-random-recordings
 * @Date: 2024-07-28 10:18
 **/
public class RemoveElement {
    public int removeElement(int[] nums  ,int val) {
        int length=nums.length;
        int slowIndex=0;
        int fastIndex=0;
        while (fastIndex<length){
            if(nums[fastIndex]!=val){
                nums[slowIndex++]=nums[fastIndex];
            }
            fastIndex++;
        }
        return slowIndex;
    }
}
